def f_map(map):
   c=len(map)
   r=len(map[0])
   for i in range(0,c-1):
       for j in range(0,r-1):
           if map[i][j]==1 and (map[i][j-1]==0 or map[i][j+1]==0 or map[i-1][j]==0 or map[i+1][j]==0):
               map[i][j]=9
   print(map)
   return map

map1=[[2, 2, 2, 2, 2, 2, 2, 2, 0, 1, 1, 1, 1, 1, 1, 1],
[2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 1, 1, 1, 1, 1, 1],
[2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1],
[2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1],
[2, 2, 2, 3, 3, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1],
[3, 3, 3, 3, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1],
[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],
[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]
f_map(map1)